# SSP Plugin (Stevens Semantic Signal Processing Project)
#
#   Copyright (C) 2011 xxu7@stevens.edu
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>. 
   
GCC=gcc-4.5
PLUGIN_SOURCE_FILES= ssp-plugin.c gcc-plugin-api.c
PLUGIN_OBJECT_FILES= $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
GCCPLUGINS_DIR:= $(shell $(GCC) -print-file-name=plugin)
CFLAGS = $(shell mysql_config --cflags) -I$(GCCPLUGINS_DIR)/include -fPIC -O2
LDFLAGS = $(shell mysql_config --libs) 

plugin.so: $(PLUGIN_OBJECT_FILES)
	 $(GCC) $(LDFLAGS) -shared $(PLUGIN_OBJECT_FILES) -o plugin.so 

ssp-plugin.o:
	$(GCC) $(CFLAGS) -c ssp-plugin.c

gcc-plugin-api.o:
	$(GCC) $(CFLAGS) -c gcc-plugin-api.c
    

.PHONY : install 
install:
	mkdir -p /opt/ssp_plugin
	install -m 0755 plugin.so /opt/ssp_plugin/
	cp -R ./plib /opt/ssp_plugin/
	install -m 0755 ssp /usr/local/bin/
	install -m 0755 ssp++ /usr/local/bin/

    
.PHONY : clean
clean:
	rm -rf *.o *.so *.png

    
